package com.lxyk.service.student.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lxyk.dao.student.CommonDao;
import com.lxyk.domain.Student;
import com.lxyk.domain.StudentVO;
import com.lxyk.service.student.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

@Service
@Transactional
public class CommonServiceImpl implements CommonService {

    @Autowired
    private CommonDao commonDao;

    @Override
    public PageInfo<StudentVO> findStudentByCid(Integer cid, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<StudentVO> list = commonDao.findStudentByCid(cid);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<StudentVO> findStudentByCondition(StudentVO vo, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<StudentVO> list = commonDao.findStudentByCondition(vo);
        return new PageInfo<>(list);
    }

    @Override
    public void addStudent(StudentVO vo) {
        commonDao.addStudent(vo);
    }

    @Override
    public StudentVO findStudentById(Integer id) {
        return commonDao.findStudentById(id);
    }

    @Override
    public void updateStudent(Student student) {
        commonDao.updateStudent(student);
    }

    @Override
    public StudentVO findDetailById(Integer id) {
        return commonDao.findDetailById(id);
    }

    @Override
    public StudentVO findClassByCid(Integer cid) {
        return commonDao.findClassByCid(cid);
    }

}
